import { Component, Input } from '@angular/core';

import { CompanyEsgService } from '../companyEsg.service';
import { EsgIndustryLeadPersonnel } from './models/EsgIndustryLeadPersonnel.model';
import { ResearchState } from '../../../research.service';

/**
 * Company ESG industry lead component
 * 
 * Author: Andrei Istrate
 * Date: 07.03.2018
 */
@Component({
    selector: 'esg-industry-lead-personnel',
    templateUrl: './esgIndustryLeadPersonnel.component.html'
})
export class EsgIndustryLeadPersonnelComponent {
    @Input() companyId: string;
    @Input() comprehensiveEsgResearchState: ResearchState;
    @Input() coreEsgResearchState: ResearchState;

    public esgIndustryLeadPersonnel: EsgIndustryLeadPersonnel;
    constructor(
        private companyEsgService: CompanyEsgService) { }

    ngOnInit() {
        if (this.comprehensiveEsgResearchState == ResearchState.ResearchAvailable) {
            this.companyEsgService.getEsgIndustryLeadPersonnel(this.companyId).subscribe(data => {
                this.esgIndustryLeadPersonnel = data;
            });
        }
        else if (this.coreEsgResearchState == ResearchState.ResearchAvailable) {
            this.esgIndustryLeadPersonnel = new EsgIndustryLeadPersonnel();
            this.esgIndustryLeadPersonnel.name = "Terence Berkleef";
            this.esgIndustryLeadPersonnel.photoUrl = this.companyEsgService.getResearchProductManagerImage();
        };
    }

    ngOnDestroy() {
    }
}